<template>
	<scroll-view scroll-y @scrolltolower="getList()" @refresherrefresh="getList(true)" :refresher-enabled="true"
		:refresher-triggered="refresherTriggered">
		<view class="waybill-box">
			<waybill-item class="waybill-item" v-for="(item,index) in list" :key="index">
				<view class="waybill-btn">
					<view class="btn">
						<text>复制</text>
					</view>
					<view class="btn">
						<text>取消</text>
					</view>
					<view class="btn">
						<text>出车前检查</text>
					</view>
				</view>
			</waybill-item>
			<view class="get-more" v-show="getMoreStatus">
				<text>正在加载更多。。。</text>
			</view>
		</view>
	</scroll-view>
</template>

<script>
	import waybillItem from "@/components/tool-card/task_item.vue"
	export default {
		components: {
			waybillItem
		},
		props: {
			// 0：全部，1：已创建，2：运输中，3：已完成
			type: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				refresherTriggered: false,
				getMoreStatus: false,
				list: [],
			};
		},
		methods: {
			// 作废运单
			toVoid(id) {
				uni.showModal({
					title: '运单状态变更',
					content: '确定将当前运单状态变更为作废运单？',
					success: (res) => {
						if (res.confirm) {
							this.historyList = [];
							uni.setStorage({
								key: 'historyList',
								data: []
							})
						}
					}
				});
			},
			// 加载，刷新
			getList(isRefresh = false) {
				if (isRefresh) {
					this.list = [];
					this.refresherTriggered = true
					setTimeout(() => {
						this.refresherTriggered = false;
					}, 1000)
				} else {
					this.getMoreStatus = true;
					setTimeout(() => {
						this.getMoreStatus = false
					}, 1000)
				}
				setTimeout(() => {
					var list = this.list
					for (var i = 0; i < 10; i++) {
						list.push({
							text: this.type + '-' + i
						})
					}
				}, 1000)
			}
		},
		mounted() {
			// 页面初始化，请求一次数据
			this.getList(true);
		},
	}
</script>

<style lang="scss" scoped>
	.waybill-box {
		padding: 20rpx 0 84rpx;
		position: relative;

		.waybill-item {
			margin-bottom: 20rpx;

			.waybill-btn {
				text-align: right;

				padding: 35rpx;

				.btn {
					display: inline-block;
					line-height: 1em;
					font-size: 28rpx;
					padding: 0.4em 1em;
					border: 3rpx solid $app-color;
					border-radius: 30rpx;
					margin-left: 15rpx;

					text {
						color: $app-color;
					}
				}
			}
		}

		.get-more {
			position: absolute;
			bottom: 0;
			left: 0;
			right: 0;
			text-align: center;
			line-height: 3em;
			font-size: 28rpx;
			color: #666666;
		}
	}
</style>
